//========encoding:utf-8=========
/*
 * @describe:  三目运算符
 * @author:mhao
 * @copyright:chinasoft.cn
 * @date:2020年3月30日   下午3:32:34
 */
package edu.chinasoft.service;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import edu.chinasoft.domain.Application;
import edu.chinasoft.domain.PageUnitForApplication;
import edu.chinasoft.domain.Role;
import edu.chinasoft.domain.User;
import edu.chinasoft.mapper.ApplicationMapper;
@Service("applicationService")
public class ApplicationServiceImp implements ApplicationService{
	@Qualifier("applicationMapper")
	@Autowired
	private ApplicationMapper applicationMapper;
	private Logger logger = LoggerFactory.getLogger(ApplicationServiceImp.class);
	@Override
	public PageUnitForApplication getRecordNumById(User user) {
		// TODO Auto-generated method stub
		logger.info("ApplicationServiceImp>>>getRecordNumById start ……");
		PageUnitForApplication recordNum = applicationMapper.getRecordNumById(user);
		logger.info("ApplicationServiceImp>>>getRecordNumById end ……");
		return recordNum;
	}
	@Override
	public List<Application> selectUnitApplicationById(Map<String, Object> map) {
		// TODO Auto-generated method stub
		logger.info("ApplicationServiceImp>>>selectUnitApplicationById start ……");
		List<Application> applicationList = applicationMapper.selectUnitApplicationById(map);
		logger.info("ApplicationServiceImp>>>selectUnitApplicationById end ……");
		return applicationList;
	}
	//添加
	@Transactional(readOnly=true,propagation=Propagation.SUPPORTS)
	@Override
	public Role selectRoleByUser(User user) {
		// TODO Auto-generated method stub
		logger.info("ApplicationServiceImp>>>selectRoleByUser start ……");
		Role role = applicationMapper.selectRoleByUser(user);
		logger.info("ApplicationServiceImp>>>selectRoleByUser end ……");
		return role;
	}
	@Transactional(readOnly=true,propagation=Propagation.SUPPORTS)
	@Override
	public List<User> selectUserByRole(Role role) {
		// TODO Auto-generated method stub
		logger.info("ApplicationServiceImp>>>selectUserByRole start ……");
		List<User> userList = applicationMapper.selectUserByRole(role);
		logger.info("ApplicationServiceImp>>>selectUserByRole end ……");
		return userList;
	}
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED)
	@Override
	public boolean insertApplication(Application application) {
		// TODO Auto-generated method stub
		logger.info("ApplicationServiceImp>>>insertApplication start ……");
		boolean result_application = applicationMapper.insertApplication(application);
		boolean result_item = applicationMapper.insertItem(application);
		logger.info("ApplicationServiceImp>>>insertApplication end ……");
		return result_application&&result_item;
	}
	//提交
	@Transactional(readOnly=true,propagation=Propagation.SUPPORTS)
	@Override
	public PageUnitForApplication selectApplicationById(User user) {
		// TODO Auto-generated method stub
		   logger.info("ApplicationServiceImp>>>getNoSubmitApplicationRecordById start ……");
		PageUnitForApplication recordNum =applicationMapper.getNoSubmitApplicationRecordById(user);
		   logger.info("ApplicationServiceImp>>>getNoSubmitApplicationRecordById end ……");
		return recordNum;
	}
	@Transactional(readOnly=true,propagation=Propagation.SUPPORTS)
	@Override
	public List<Application> selectNoSubmitApplicationById(Map<String, Object> map) {
		// TODO Auto-generated method stub
		 logger.info("ApplicationServiceImp>>>selectNoSubmitApplicationById start ……");
		 List<Application> applicationList = applicationMapper.selectNoSubmitApplicationById(map);
		 logger.info("ApplicationServiceImp>>>selectNoSubmitApplicationById end ……");
		return applicationList;
	}
	@Override
	public PageUnitForApplication getNoSubmitApplicationRecordById(User user) {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public boolean updateApplicationById(Application application) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean deleteApplication(Application application) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public PageUnitForApplication getApprovalApplicationRecordById(User user) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public List<Application> selectApprovalApplicationById(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public Application selectApplicationById(Application application) {
		// TODO Auto-generated method stub
		return null;
	}
	
}
